import './App.css'
import {BrowserRouter,Routes,Route} from 'react-router-dom'
import Layout01 from './layouts/Layout01'
import Layout02 from './layouts/Layout02'
import Home from './views/Home'
import PetInfo from './views/PetInfo'
import Login from './views/Login'
import Reg from './views/Reg'
import Pet from './views/Pet'
import Apply from './views/Apply'
import PersonalCenter from './views/PersonalCenter'

import { observer } from 'mobx-react-lite'
import userStore from './stores/UserStore'
import RootContext from './contexts/RootContext'
import AdoptCenter from './views/AdoptCenter'

function App() {

  return (
    <RootContext.Provider value={{curUser:userStore.getUser()}}>
    <BrowserRouter>
      <Routes>
        {/* 无需先登录 */}
        <Route path='' element={<Layout01/>}>
          <Route path='/home' element={<Home/>}></Route>
          <Route path="/login" element={<Login/>}></Route>
          <Route path="/reg" element={<Reg/>}></Route>
        </Route>
        {/* 需要先登录 */}
        <Route path='' element={<Layout02/>}>
          <Route path='/petInfo' element={<PetInfo/>}></Route>
          <Route path="/adoptcenter" element={<AdoptCenter/>}></Route>
          <Route path="/pet" element={<Pet/>}></Route>
        <Route path="/personalcenter" element={<PersonalCenter/>}></Route>
        <Route path="/apply/:petId" element={<Apply/>}></Route>
        </Route>
      </Routes>
    </BrowserRouter>
    </RootContext.Provider>
  )
}

export default observer(App)